//
// Created by asus on 2020/3/12.
//
#include <iostream>
#define test0312 test0312
void swap1(int x,int y);
void swap2(int *x,int *y);
void swap(int &x,int &y);
int test0312(){
    int a=1,b=2;
    printf("before:a=%d,b=%d\n",a,b);
    swap(a,b);
    printf("after:a=%d,b=%d\n",a,b);
    return 0;
}

//形参的变化不会引起实参的变化，起不到交换作用
void swap1(int x,int y){
    int temp =x;
    x=y;
    y=temp;
}
//可以
void swap2(int *x,int *y){
    int temp =*x;
    *x=*y;
    *y=temp;
}

void swap(int &x,int &y){
    int temp =x;
    x=y;
    y=temp;
}